﻿using RaptorEngine;
using RaptorEngine.Components;
using Microsoft.Xna.Framework;
using RaptorEngine.Components.Drawable;
using RaptorEngine.Components.CollidableComponent;
using OilRigSumoWrestlers.Controllables;
using OilRigSumoWrestlers.Components;
using Microsoft.Xna.Framework.Graphics;
using OilRigSumoWrestlers.Actions;
using OilRigSumoWrestlers.Entities;

namespace OilRigSumoWrestlers.Scenes
{
    class SingleplayerScene : Scene
    {
        public SingleplayerScene(bool network)
            : base(network)
        {
            Camera = new Camera(Vector3.Forward, new Vector3(0, 50, 50));

            CreateScene();
        }

        private void CreateScene()
        {
            /*Entity snoplao = new Entity();
            snoplao.Position = new Vector3(-1, 0, 10);
            snoplao.AddComponent(new DrawableModel(snoplao, GameEngine.Instance.Load<Model>("Models/snowplow"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
            snoplao.AddComponent(new TestControllable(snoplao));

            Entity franky = new Entity();
            franky.Position = new Vector3(50, 50, 0);
            franky.AddComponent(new DrawableSprite(franky, GameEngine.Instance.Load<Texture2D>("Images/franky2")));
            //franky.AddComponent(new TestControllable(franky));

            Entity ball = new Entity();
            ball.Position = new Vector3(0, 0, 0);
            ball.AddComponent(new DrawableModel(ball, GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));

            Entity e = new Entity();
            e.Scale = .03f;
            e.AddComponent(new DrawableAnimation(e, GameEngine.Instance.Load<Model>("Models/dude"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
			*/
            Entity ball = new Entity();
            ball.Position = new Vector3(-9, 20, 0);
            ball.AddComponent(new DrawableModel(ball, GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
            ball.AddComponent(new Collidable(ball, new NormalBounce(1), GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), true, (int)CollisionType.Player));
            ball.AddComponent(new Movable(ball, GameConstant.PLAYER_MASS));
            ball.AddComponent(new TestControllable(ball));
            AddEntity(ball);

			Entity cube = new Entity();
			cube.Position = new Vector3(0, -5, 0);
			cube.Scale = 20;
			cube.AddComponent(new DrawableModel(cube, GameEngine.Instance.Load<Model>("Models/Cube/cube"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
			cube.AddComponent(new Collidable(cube, new Floor(1), GameEngine.Instance.Load<Model>("Models/Cube/cube"), false, (int)CollisionType.Ground));
			AddEntity(cube);

            //Entity ball2 = new Entity() { };
            //ball2.Position = new Vector3(0, 0, 0);
            //ball2.AddComponent(new DrawableModel(ball2, GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
            //ball2.AddComponent(new Collidable(ball2, new NormalBounce(), GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), true));
            //ball2.AddComponent(new Movable(ball2, 10f));
            //ball2.AddComponent(new TestControllable2(ball2));
            //AddEntity(ball2);

            //Entity stillBall = new Entity();
            //stillBall.Position = new Vector3(9, -.5f, -.5f);
            //stillBall.AddComponent(new DrawableModel(stillBall, GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), new BasicEffect(GameEngine.Instance.Render.GraphicsDevice)));
            //stillBall.AddComponent(new Collidable(stillBall, new NormalBounce(), GameEngine.Instance.Load<Model>("Models/Sphere/sphere_mapped"), true));
            //AddEntity(stillBall);



            //for (int i = 0; i < 10; i++)

            Entity AI = new FuzzyAI(new Vector3(5, 20f, 0f));
            ((AIComponent)AI.Components[ComponentType.Controllable]).AddEnemy(ball);
            AddEntity(AI);


            //AddEntity(e);
            //AddEntity(franky);
            //AddEntity(snoplao);


            //e = new Entity();
            //e.AddComponent(new DrawableText(e, GameEngine.Instance.Load<SpriteFont>("Fonts/testFont"), "Detta fungerar."));
            //AddEntity(e);

            //e = new Entity();
            //e.AddComponent(new DrawableSprite(e, GameEngine.Instance.Load<Texture2D>("Images/black"), Color.White, .7f));
            //e.Scale = GameEngine.Instance.Render.GraphicsDevice.Viewport.Width;
            //AddEntity(e);

            //e = new Entity();
            //e.Position = new Vector3(400, 100, 0);
            //e.AddComponent(new DrawableSprite(e, GameEngine.Instance.Load<Texture2D>("Images/Frankytauro")));
            //AddEntity(e);

            //e = new Entity();
            //e.Position = new Vector3(GameEngine.Instance.Render.GraphicsDevice.Viewport.Width / 2 + 20, GameEngine.Instance.Render.GraphicsDevice.Viewport.Height / 2 + 130, 0);
            //e.AddComponent(new DrawableText(e, GameEngine.Instance.Load<SpriteFont>("Fonts/testFont"), "KENTAURU MOODO!!!!"));
            //AddEntity(e);

        }
    }
}
